package com.yanqu.road.server.cmd.activity.newyear2023.redpacket.cross;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FireWorkProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.bulletscreen.BulletScreenModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_FIREWORK_RP_ROB_REWARD, desc = "抢红包获得奖励")
public class CrossFireWorkRobRewardCmd extends AbstractCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FireWorkProto.CrossFireWorkTableRobRewardReqMsg reqMsg = FireWorkProto.CrossFireWorkTableRobRewardReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(packet.getPlayerId());
        if(player != null){
            player.getModule(CurrencyModule.class).addCurrency(GameConfig.GAME_MONEY_INGOTS + "=" + reqMsg.getRewardValue(), eLogMoneyType.FireWork2023,eLogMoneyType.FireWork2023ActivityRob);
            player.getModule(BulletScreenModule.class).robAddCanBarrageTimes(activityId);
        }
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
